/*
 * =====================================================================================
 *
 *       Filename:  timer_wheel.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  05/21/2011 03:18:13 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ken Chen (Ken), chen_kenz@emc.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#ifndef _TIMER_WHEEL_H_
#define _TIMER_WHEEL_H_

typedef void (*timer_callback)(void*);
struct timer_wheel_base;
struct timer_entry;

struct timer_entry_list
{
  struct timer_entry_list* prev;
  struct timer_entry_list* next;
};

struct timer_entry
{
  struct timer_entry_list pending_timers;
  timer_callback callback;
  void* data;
  unsigned long expired_interval;
	int pending;
  struct timer_wheel_base* base;
};

#ifdef __cplusplus
extern "C" {
#endif

void init_timer(struct timer_entry* tim, 
                timer_callback func, 
                void* data, 
                unsigned long interval);
int add_timer(struct timer_entry* tim);
int delete_timer(struct timer_entry* tim);
int schedule_timers(void);

#ifdef __cplusplus
}
#endif

#endif /*_TIMER_WHEEL_H_*/

